﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[AddComponentMenu("MyGame/Rocket")]
public class Rocket : MonoBehaviour {

    //子弹的飞行速度
    public float m_speed = 10;
    //生存时间
    public float m_liveTime = 1;

    //威力
    public float m_power = 1.0f;
    protected Transform m_tranform;

    //
    void Awake()
    {
        m_tranform = transform;
    }
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	protected virtual void Update () {
        m_liveTime -= Time.deltaTime;
        if (m_liveTime<=0)
        {
            destory();
        }
		  m_tranform.Translate(new Vector3(0,0,-m_speed*Time.deltaTime));

	} 
    

     void destory()
    {
        Destroy(gameObject);
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Enemy"||other.tag =="EnemyRocket")
        {
            destory();
        }
    }
    
}
